﻿using System;
using System.Windows;
using System.Windows.Data;

namespace Dsl.Ped.Controls.ProjectiveControl.Converters
{
    /// <summary>
    /// Converter of the <see cref="ViewMode"/> to the <see cref="Visibility"/>.
    /// </summary>
    public class ViewModeToVisibilityConverter : IValueConverter
    {
        #region IValueConverter Members

        /// <summary>
        /// Converts <see cref="ViewMode"/> into <see cref="Visibility"/>
        /// If the <see cref="ViewMode"/> is <see cref="ViewMode.Extended"/> <see cref="Visibility.Visible"/> is returned,
        /// <see cref="Visibility.Collapsed"/> otherwise
        /// </summary>
        /// <param name="value">Value to be converted</param>
        /// <param name="targetType">Target type of the conversion</param>
        /// <param name="parameter">Parameter of the conversion</param>
        /// <param name="culture">Culture under which the conversion is done</param>
        /// <returns><see cref="Visibility.Visible"/> in case <see cref="ViewMode"/> is <see cref="ViewMode.Extended"/>, <see cref="Visibility.Collapsed"/> otherwise</returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return Visibility.Collapsed;

            var valueStrong = (ViewMode)value;

            return valueStrong == ViewMode.Extended ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
